import request from '@/config/axios'

// 不良品记录 VO
export interface DefectiveProductRecordVO {
  id: string // 主键
  orderCode: string // 订单号
  flex: string // 规格型号
  orderDetailId: string // 订单详情ID
  internalCode: string // 内码
  defectiveReason: string // 不良品原因
  defectiveItem: string // 不良品选项
  operatorUser: string // 操作员
  operatorTime: Date // 操作时间
}

// 不良品记录 API
export const DefectiveProductRecordApi = {
  // 查询不良品记录分页
  getDefectiveProductRecordPage: async (params: any) => {
    return await request.get({ url: `/project/defective-product-record/page`, params })
  },

  // 查询不良品记录详情
  getDefectiveProductRecord: async (id: number) => {
    return await request.get({ url: `/project/defective-product-record/get?id=` + id })
  },

  // 新增不良品记录
  createDefectiveProductRecord: async (data: DefectiveProductRecordVO) => {
    return await request.post({ url: `/project/defective-product-record/create`, data })
  },

  // 修改不良品记录
  updateDefectiveProductRecord: async (data: DefectiveProductRecordVO) => {
    return await request.put({ url: `/project/defective-product-record/update`, data })
  },

  // 删除不良品记录
  deleteDefectiveProductRecord: async (id: number) => {
    return await request.delete({ url: `/project/defective-product-record/delete?id=` + id })
  },

  // 导出不良品记录 Excel
  exportDefectiveProductRecord: async (params) => {
    return await request.download({ url: `/project/defective-product-record/export-excel`, params })
  }
}
